import request from '@/utils/request.js'
let token = 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3MDM4MjQ0NDAsInVzZXJfaWQiOjEsInJlZnJlc2giOmZhbHNlLCJ2ZXJpZmllZCI6dHJ1ZX0.p6z-3K-zczqm2fe2MMGoGjj0-_wZUIvaY9s_dM1XHsk'
let baseurl = 'http://api-toutiao-web.itheima.net/'

// 上传图片
// export const reqUploadImage = data => {
//   return request({
//     method: 'POST',
//     url: '/v1_0/upload',
//     data,
//   })
// }


// 获取素材图片(该接口已经不能用,用线上的)
export const reqGetImage = params => {
  return request({
    method: 'GET',
    url: baseurl + 'mp/v1_0/user/images',
    params,
    headers: {
      Authorization: token
    }
  })
}

// 收藏/取消收藏当前素材图片
export const reqStartImage = (imgId,collect) => {
  console.log(imgId,collect)
  return request({
    method: 'PUT',
    url: baseurl + `mp/v1_0/user/images/${imgId}`,
    data: {
      collect
    },
    headers: {
      Authorization: token
    }
  })
}

// 删除素材图片
export const reqDeleteImage = imgId => {
  return request({
    method: 'Delete',
    url: baseurl + `mp/v1_0/user/images/${imgId}`,
    headers: {
      Authorization: token
    }
  })
}

export default {
  token,
  baseurl
}
